/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.dao;

import com.thinkgem.jeesite.common.persistence.CrudDao;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.sys.entity.User;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户DAO接口
 * @author ThinkGem
 * @version 2014-05-16
 */
@MyBatisDao
public interface UserDao extends CrudDao<User> {
	
	/**
	 * 根据登录名称查询用户
	 * @param user
	 * @return
	 */
	User getByLoginName(User user);

	/**
	 * 通过OfficeId获取用户列表，仅返回用户id和name（树查询用户时用）
	 * @param user
	 * @return
	 */
	List<User> findUserByOfficeId(User user);
	
	/**
	 * 查询全部用户数目
	 * @return
	 */
	long findAllCount(User user);
	
	/**
	 * 更新用户密码
	 * @param user
	 * @return
	 */
	int updatePasswordById(User user);
	
	/**
	 * 更新登录信息，如：登录IP、登录时间
	 * @param user
	 * @return
	 */
	int updateLoginInfo(User user);

	/**
	 * 删除用户角色关联数据
	 * @param user
	 * @return
	 */
	int deleteUserRole(User user);
	
	/**
	 * 插入用户角色关联数据
	 * @param user
	 * @return
	 */
	int insertUserRole(User user);
	
	/**
	 * 更新用户信息
	 * @param user
	 * @return
	 */
	int updateUserInfo(User user);

    List<User> getUserByMobile(String mobile);
    List<User> findUsersByCompanyAndOffice(@Param("companyId")String companyId, @Param("officeId")String officeId);
    List<User> findUsersByCompanyOfficeAndType(@Param("companyId")String companyId, @Param("officeId")String officeId,@Param("userType")String userType);
    List<User> findUsersByCompanyOfficeAndTypeAndMobile(@Param("companyId")String companyId, @Param("officeId")String officeId,@Param("userType")String userType,@Param("mobile")String mobile);

	User getCheckUser(@Param("companyId")String companyId, @Param("enname")String enname);

	int delApplyUserStatus(@Param("users")String users,@Param("status")String status);
	int delApprovalUserStatus(@Param("users")String users,@Param("status")String status);

	int batchUpdateUserStatus(@Param("users")String users,@Param("status")String status,@Param("checker")String checker, @Param("comment")String comment);

	User getUserByToken(@Param("token")String token);

	void setUserToken(User user);
	
	int updateUserStatus(User user);
	
	long findUsersCountForTheArea(User user);
	User getMaintainerForUser(@Param("companyId")String companyId, @Param("officeId")String officeId,@Param("userType")String userType);
    List<User> findUserForCheck(User user, @Param("users")List<User> list,@Param("status")String status);
	List<User> findUserForCheck(@Param("users")List<User> list,@Param("status")String status);
    List<User> findAreaUsers();

    List<User> findMaintainAndNormalUsersInCompany(@Param("companyId")String companyId);
    List<User> findAllUsersInCompany(@Param("companyId")String companyId);
    List<User> findAllUsersInCompanyAndOffice(@Param("companyId")String companyId,@Param("officeId")String officeId);


}
